﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace NETCORE.EF.DBFirst.Models
{
    public partial class DBContext : DbContext
    {
        public DBContext()
        {
        }

        public DBContext(DbContextOptions<DBContext> options)
            : base(options)
        {
        }

        public virtual DbSet<AlogFilestream> AlogFilestreams { get; set; } = null!;
        public virtual DbSet<AlogUserfile> AlogUserfiles { get; set; } = null!;
        public virtual DbSet<AlogUserlogin> AlogUserlogins { get; set; } = null!;

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseMySql( Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.33-mysql"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.UseCollation("utf8mb4_0900_ai_ci")
                .HasCharSet("utf8mb4");

            modelBuilder.Entity<AlogFilestream>(entity =>
            {
                entity.ToTable("alog_filestream");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.CreateData)
                    .HasColumnType("datetime")
                    .HasColumnName("createData");

                entity.Property(e => e.CreateId).HasColumnName("createId");

                entity.Property(e => e.DeletedData)
                    .HasColumnType("datetime")
                    .HasColumnName("deletedData");

                entity.Property(e => e.DeletedId).HasColumnName("deletedId");

                entity.Property(e => e.IsDeleted)
                    .HasColumnName("isDeleted")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.LastmodifyData)
                    .HasColumnType("datetime")
                    .HasColumnName("lastmodifyData");

                entity.Property(e => e.LastmodifyId).HasColumnName("lastmodifyId");

                entity.Property(e => e.Level).HasMaxLength(50);

                entity.Property(e => e.Logger).HasMaxLength(100);

                entity.Property(e => e.Message).HasMaxLength(2000);

                entity.Property(e => e.Remark)
                    .HasMaxLength(200)
                    .HasColumnName("remark");
            });

            modelBuilder.Entity<AlogUserfile>(entity =>
            {
                entity.ToTable("alog_userfile");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.CreateData)
                    .HasColumnType("datetime")
                    .HasColumnName("createData");

                entity.Property(e => e.CreateId).HasColumnName("createId");

                entity.Property(e => e.DeletedData)
                    .HasColumnType("datetime")
                    .HasColumnName("deletedData");

                entity.Property(e => e.DeletedId).HasColumnName("deletedId");

                entity.Property(e => e.FileId).HasColumnName("fileId");

                entity.Property(e => e.FileName)
                    .HasMaxLength(200)
                    .HasColumnName("fileName");

                entity.Property(e => e.FileType)
                    .HasMaxLength(200)
                    .HasColumnName("fileType");

                entity.Property(e => e.IsDeleted)
                    .HasColumnName("isDeleted")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.LastmodifyData)
                    .HasColumnType("datetime")
                    .HasColumnName("lastmodifyData");

                entity.Property(e => e.LastmodifyId).HasColumnName("lastmodifyId");

                entity.Property(e => e.Option)
                    .HasMaxLength(50)
                    .HasColumnName("option");

                entity.Property(e => e.SenceIds)
                    .HasMaxLength(200)
                    .HasColumnName("senceIds");

                entity.Property(e => e.Uid).HasColumnName("uid");
            });

            modelBuilder.Entity<AlogUserlogin>(entity =>
            {
                entity.ToTable("alog_userlogin");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Account)
                    .HasMaxLength(200)
                    .HasColumnName("account");

                entity.Property(e => e.CreateData)
                    .HasColumnType("datetime")
                    .HasColumnName("createData");

                entity.Property(e => e.CreateId).HasColumnName("createId");

                entity.Property(e => e.DeletedData)
                    .HasColumnType("datetime")
                    .HasColumnName("deletedData");

                entity.Property(e => e.DeletedId).HasColumnName("deletedId");

                entity.Property(e => e.IsDeleted)
                    .HasColumnName("isDeleted")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.LastmodifyData)
                    .HasColumnType("datetime")
                    .HasColumnName("lastmodifyData");

                entity.Property(e => e.LastmodifyId).HasColumnName("lastmodifyId");

                entity.Property(e => e.Option)
                    .HasMaxLength(50)
                    .HasColumnName("option");

                entity.Property(e => e.Uid).HasColumnName("uid");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
